﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Globalization;

namespace RESP_IIWaterAssessment
{
    public partial class EmployeesAVPForm : Form
    {
        string AVPName;
        public int memberID;
        public RESP_IIWaterAssessment.Entity.tb_member member { get; set; }

        bool InsertRec;

        public EmployeesAVPForm(int avpID, bool InsertRec, RESP_IIWaterAssessment.Entity.tb_member member) // добавление true, редактирование false
        {
            this.ShowInTaskbar = false;
            this.InsertRec = InsertRec;
            InitializeComponent();
            this.AVPName = UtilClass.GetAVPName(avpID);
            AVPNameLabel.Text += UtilClass.GetAVPName(avpID);
            cbEducation.Items.AddRange(UtilClass.GetCategory("Education"));

            if (!InsertRec)
            {
                this.member = member;
                dtpBDay.Value = (DateTime)member.BirthDate;
                tbContactInfo.Text = member.ContactInfo;
                cbEducation.Text = UtilClass.GetCategoryDisplayName((int)member.Education, "Education");
                tbPosition.Text = member.Position;
                if (member.TypeMeeting==2)
                    rbCommision.Checked = true;
                if (member.TypeMeeting == 3)
                    rbConflCommision.Checked = true;
                if (member.TypeMeeting == 4)
                    rbSovet.Checked = true;
                tbName.Text = member.Name;
                tbWorkPlace.Text = member.JobPlace;
            }

        }

        private void buttonOK_Click(object sender, EventArgs e)
        {
            member = new RESP_IIWaterAssessment.Entity.tb_member
            {
                BirthDate = dtpBDay.Value,
                ContactInfo = tbContactInfo.Text,
                Education = UtilClass.GetCategoryValue("Education", cbEducation.Text),
                JobPlace = tbWorkPlace.Text,
                MemberType = rbCommision.Checked,
                Name = tbName.Text,
                Position = tbPosition.Text
            };
            if (rbCommision.Checked)
                member.TypeMeeting = 2;
            if (rbConflCommision.Checked)
                member.TypeMeeting = 3;
            if (rbSovet.Checked)
                member.TypeMeeting = 4;
            DialogResult = DialogResult.OK;
            this.Close();
        }

        private void buttonCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void EmployeesAVPForm_Load(object sender, EventArgs e)
        {
            

        }
    }
}
